﻿namespace ListViewDemo;

public partial class MainPage : ContentPage {
    int count = 0;

    public MainPage() {
        InitializeComponent();

        var contacts = new List<Contact> {
            new() { Name = "张三", PhoneNumber = "+8613800138000" },
            new() { Name = "张四", PhoneNumber = "+8613800138001" },
            new() { Name = "张五", PhoneNumber = "+8613800138002" },
        };

        MainListView.ItemsSource = contacts;
    }

    private void Button_OnClicked(object sender, EventArgs e) {
        var button = (Button)sender;
        var bindingContext = button.BindingContext;
        var contact = (Contact)bindingContext;
        DisplayAlert("Message", $"You clicked {contact.Name}", "OK");
    }
}

public class Contact {
    public string Name { get; set; }
    public string PhoneNumber { get; set; }
}